package com.dronff.factory;


import com.dronff.BlockSend;
import com.dronff.connection.TangConnection;
import com.dronff.interceptor.TangProtocolRPCProxyObjectInterceptor;
import net.sf.cglib.proxy.Enhancer;

public class ProxyRemoteInvokerFactory {
    public static <T> T createProxyRemoteInvoker(BlockSend blockSend, Class<T> clazz){
        TangProtocolRPCProxyObjectInterceptor tangProtocolRPCProxyObjectInterceptor = new TangProtocolRPCProxyObjectInterceptor();
        tangProtocolRPCProxyObjectInterceptor.setBlockSend(blockSend);
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(tangProtocolRPCProxyObjectInterceptor);
        return (T)enhancer.create();
    }
}
